Current Location: Home> Function Categories> date_date_set

date_date_set

DateTime::setDate alias - Set the date of the DateTime object
Name:date_date_set
Category:Date and time
Programming Language:php
One-line Description:Set a new date.

Definition and usage

date_date_set() function sets a new date.

Example

Return a new DateTime object, set a new date, and format the date:

 <?php
$date = date_create ( ) ;
date_date_set ( $date , 2020 , 10 , 15 ) ;
echo date_format ( $date , "Y/m/d" ) ;
?>

Try it yourself

grammar

 date_date_set ( object , year , month , day ) ;
parameter describe
object Required. Specifies the DateTime object returned by date_create() .
year Required. The year in the specified date.
month Required. Months in the specified date.
day Required. The date in the specified date.
Similar Functions
Popular Articles